package com.infolab.aims.domain.receive;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.infolab.aims.common.SpecialMuLineToStringStyle;
import com.infolab.aims.common.bean.AbstractModelBean;
import com.infolab.aims.domain.asset.AssetModel;

@Entity
@Table(name="AMTB_DELIVERYORDER_EQUIPMENT")
public class DeliveryOrderEquipment extends AbstractModelBean  {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer deliveryOrderEquipmentId;
	
	@ManyToOne
	@JoinColumn(name="deliveryOrderId")
	private DeliveryOrder deliveryOrder;
	
	@ManyToOne
	@JoinColumn(name="assetModelId")
	private AssetModel assetModel;
	
	private String purchasedSerialNo;
	
	private String receivedSerialNo;
	
	private String assetTag;
	
	private Float unitPrice;
	
	@Transient
	private boolean deleted;
	
	@Transient
	private boolean active;
	
	private String status;

	

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public Integer getDeliveryOrderEquipmentId() {
		return deliveryOrderEquipmentId;
	}

	public void setDeliveryOrderEquipmentId(Integer deliveryOrderEquipmentId) {
		this.deliveryOrderEquipmentId = deliveryOrderEquipmentId;
	}

	public DeliveryOrder getDeliveryOrder() {
		return deliveryOrder;
	}

	public void setDeliveryOrder(DeliveryOrder deliveryOrder) {
		this.deliveryOrder = deliveryOrder;
	}

	public AssetModel getAssetModel() {
		return assetModel;
	}

	public void setAssetModel(AssetModel assetModel) {
		this.assetModel = assetModel;
	}

	public String getPurchasedSerialNo() {
		return purchasedSerialNo;
	}

	public void setPurchasedSerialNo(String purchasedSerialNo) {
		this.purchasedSerialNo = purchasedSerialNo;
	}

	public String getReceivedSerialNo() {
		return receivedSerialNo;
	}

	public void setReceivedSerialNo(String receivedSerialNo) {
		this.receivedSerialNo = receivedSerialNo;
	}

	public Float getUnitPrice() {
		return unitPrice;
	}

	public void setUnitPrice(Float unitPrice) {
		this.unitPrice = unitPrice;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	public String getAssetTag() {
		return assetTag;
	}

	public void setAssetTag(String assetTag) {
		this.assetTag = assetTag;
	}
	
	public String getAuditContentHead()
	{
		AssetModel model = assetModel;
		if(assetModel==null){
			model = new AssetModel();
		}
		
		if(deliveryOrder.getPurchaseOrder().isNewPurchaseOrder()){
		return new ToStringBuilder(this,SpecialMuLineToStringStyle.SPECIAL_MULINE_STYLE)
			.append("Asset Model", model.getAssetModelCode() + " " + model.getAssetModelName())
			.append("Unit Price",unitPrice)
			.append("Received Serial No", receivedSerialNo)
			.append("Asset Tag", assetTag)
			.toString();
		}
		else {
		return new ToStringBuilder(this,SpecialMuLineToStringStyle.SPECIAL_MULINE_STYLE)
			.append("Asset Model", model.getAssetModelCode() + " " + model.getAssetModelName())
			.append("Received Serial No", receivedSerialNo)
			.append("Asset Tag", assetTag)
			.toString();
		}
	}
	
}
